package com.ruoyi.web.controller.V2.tool.controller;

import java.util.List;

import com.ruoyi.system.model.domain.Backlist;
import com.ruoyi.system.V2.tool.service.IBacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/account/backlist")
public class BacklistController extends BaseController
{
    @Autowired
    private IBacklistService backlistService;

    /**
     */
    @GetMapping("/list")
    public TableDataInfo list(Backlist backlist)
    {
        startPage();
        List<Backlist> list = backlistService.selectBacklistList(backlist);
        return getDataTable(list);
    }


    /**
     * 我的账号
     */
    @GetMapping("/allList")
    public TableDataInfo allList(Backlist backlist)
    {
        startPage();
        List<Backlist> list = backlistService.allList(backlist);
        return getDataTable(list);
    }

    /**
     */
    @GetMapping("/export")
    public AjaxResult export(Backlist backlist)
    {
        List<Backlist> list = backlistService.selectBacklistList(backlist);
        ExcelUtil<Backlist> util = new ExcelUtil<Backlist>(Backlist.class);
        return util.exportExcel(list, "回收数据导出");
    }

    /**
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(backlistService.selectBacklistById(id));
    }

    /**
     */
    @PostMapping
    public AjaxResult add(@RequestBody Backlist backlist)
    {
        return toAjax(backlistService.insertBacklist(backlist));
    }

    /**
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Backlist backlist)
    {
        return toAjax(backlistService.updateBacklist(backlist));
    }

    /**
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(backlistService.deleteBacklistByIds(ids));
    }
}
